<?php
//RK
$parent = isset($CONFIG['parent']) ? (int)$CONFIG['parent'] : '';
$menu = Eleanor::$Cache->Get('middle_block'. Language::$main . $parent);
if($menu === false) {
	$p = $menu = $menu_bef = '';
	if($parent) {
		$R = Eleanor::$Db->Query('SELECT `parents` FROM `'.P.'menu` WHERE `id`='.$parent.' LIMIT 1');
		if(!list($p) = $R->fetch_row())
			return '';
		$p .= $parent. ',';
	}
	$r = $R = Eleanor::$Db->Query('SELECT `title`,`url`,`eval_url`,`params` FROM `'. P .'menu` INNER JOIN `'. P .'menu_l` USING(`id`) WHERE `language` IN("","'. Language::$main .'") AND `in_map`=1 AND `status`=1 AND `parents`="'. $p .'" ORDER BY `parents` ASC, `pos` ASC');
	$i = 1;
	$so = $r->num_rows;
	while($a = $r->fetch_assoc()) {
		if($a['eval_url']) {
			ob_start();
			$f = create_function('$Eleanor', $a['eval_url']);
			if($f === false) {
				ob_end_clean();
				continue;
			}
			ob_end_clean();
			$url = $f($GLOBALS['Eleanor']);
		}
		else
			$url = $a['url'];
		
		$menu_bef .= '<td><div></div></td>';
		if (strpos($a['title'], '[text]') !== false) {
			$tt = explode('[text]', $a['title']);
			$t = '<div class="body_middle_menu_title">'. $tt[0] .'</div><div class="body_middle_menu_text">'. $tt[1] .'</div>';
		} else {
			$t = '<div class="body_middle_menu_title">'. $a['title'] .'</div>';
		}
		
		$menu .= '<td class="'.( $i !== $so ? 'right_border ' : null ) . ( $i ? ' left_border' : null ).'">
		<a href="'. $url .'">
			<div class="body_middle_menu_overflow">
				'. $t .'
			</div>
			<div class="circle_container"><div class="boddy_middle_menu_circle">'. $i .'</div></div>
		</a>
		</td>';
		$i++;
	}
	$menu = '<tr id="body_middle_menu_triangles">'. $menu_bef .'</tr><tr id="body_middle_menu_links">'. $menu .'</tr>';
	Eleanor::$Cache->Put('middle_block'. Language::$main . $parent, $menu);
}
return $menu;